import {Injectable} from "@angular/core";
import {HttpService} from "../HttpService";
import {ResponseData} from "../model/ResponseData";
import {Http} from "@angular/http";
import {ms_resetPasswordFromSource} from "../model/ms_resetPasswordFromSource";


/**
 * 获得下载链接
 */
@Injectable()
export class PersonService extends HttpService {

    protected modifyPasswordURL: string = "ModifyPassword";


    constructor(private http: Http) {
        super()
    };


    public modifyPassword(resetPassword: ms_resetPasswordFromSource): Promise<ResponseData<void>> {
        this.isAjax = true;
        return this.http.post(this.prefix + this.modifyPasswordURL, {
            sourcePassword: resetPassword.encryptSourcePassword(),
            newPassword: resetPassword.encryptNewPassword()
        })
            .map(response => {
                this.isAjax = false;
                return response.json() as ResponseData<void>;
            }).toPromise();
    }


}
